export const getSetting=()=>{
  return new Promise((res,rej)=>{
    wx.getSetting({
      success: (result) => {
        res(result);
      },
      fail: (err) => {
        rej(err);
      }
    });
      
  })
}

export const chooseAddress=()=>{
  return new Promise((res,rej)=>{
    wx.chooseAddress({
      success: (result) => {
        res(result);
      },
      fail: (err) => {
        rej(err);
      }
    });
      
  })
}
export const openSetting=()=>{
  return new Promise((res,rej)=>{
    wx.openSetting({
      success: (result) => {
        res(result);
      },
      fail: (err) => {
        rej(err);
      }
    });
      
  })
}
export const showModal=({content})=>{
  return new Promise((res,rej)=>{
    wx.showModal({
      title: '提示',
      content: content,
      showCancel: true,
      cancelText: '取消',
      cancelColor: '#000000',
      confirmText: '确定',
      confirmColor: '#3CC51F',
      success:(result)=>{
        res(result);
      },
      fail:(err)=>{
        rej(err);
      }
    });
  })
}
export const showToast=({title})=>{
  return new Promise((res,rej)=>{
    wx.showToast({
      title:title,
      icon:'none',
      success:(result)=>{
        res(result);
      },
      fail:(err)=>{
        rej(err);
      }
    });
  })
}
export const login = ()=>{
  return new Promise((res,rej)=>{
    wx.login({
      timeout:10000,
      success: (result) => {
        res(result);
      },
      fail: (err) => {
        rej(err);
      }
    });
  });
}
/**
 * @param { object} pay 支付所必要的参数
 * */ 
export const requestPayment = (pay)=>{
  return new Promise((res,rej)=>{
    wx.requestPayment({
      ...pay,
      success: (result) => {
        res(result);
      },
      fail: (err) => {
        rej(err);
      }
    });
      
  });
}
